import 'package:finance_app/src/entities/format/service_and_product_entity.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/entities/product_entity.dart';
import 'package:finance_app/src/entities/services_entity.dart';
import 'package:finance_app/src/entities/setting_data_entity.dart';

serviceAndProductEntityFromJson(ServiceAndProductEntity data, Map<String, dynamic> json) {
	if (json['services'] != null) {
		data.services = ServicesEntity().fromJson(json['services']);
	}
	if (json['product'] != null) {
		data.product = ProductEntity().fromJson(json['product']);
	}
	if (json['number'] != null) {
		data.number = json['number'] is String
				? int.tryParse(json['number'])
				: json['number'].toInt();
	}
	return data;
}

Map<String, dynamic> serviceAndProductEntityToJson(ServiceAndProductEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['services'] = entity.services?.toJson();
	data['product'] = entity.product?.toJson();
	data['number'] = entity.number;
	return data;
}